using UnityEngine;

public class QualityDisplayRot : QualityDisplay
{
	public Transform arrowRotator;

	private void Awake()
	{
		SetRanges(0f, 0f, 200f, false);
	}

	public override void SetRanges(float skillDifference, float timing, float maxTiming, bool showThumb)
	{
		int num = 0;
		foreach (HitParamsDB.TimingRange range in ScriptableObjectSingleton<HitParamsDB>.instance.timing.ranges)
		{
			float f = Mathf.Min(range.timingRange.min, range.timingRange.max);
			if (!(Mathf.Sign(f) < 0f))
			{
				if (num >= layers.Count)
				{
					layers.Add(NGUITools.AddChild(layerPrefab.cachedTransform.parent.gameObject, layerPrefab.cachedGameObject).GetComponent<UISprite>());
				}
				UISprite uISprite = layers[num];
				QualityDisplayRotLayer component = uISprite.GetComponent<QualityDisplayRotLayer>();
				uISprite.cachedGameObject.SetActive(true);
				component.SetColor(range.colorTimer);
				component.SetDepth(container.depth + 10 + ScriptableObjectSingleton<HitParamsDB>.instance.timing.ranges.Count - num);
				FloatRange skillDifferenceModifiedTimingRange = range.GetSkillDifferenceModifiedTimingRange(skillDifference);
				component.SetRange(Mathf.Max(Mathf.Abs(skillDifferenceModifiedTimingRange.min), Mathf.Abs(skillDifferenceModifiedTimingRange.max)));
				num++;
			}
		}
		for (int i = num; i < layers.Count; i++)
		{
			layers[i].cachedGameObject.SetActive(false);
		}
		float normTiming = ScriptableObjectSingleton<HitParamsDB>.instance.timing.GetNormTiming(timing, maxTiming);
		if (arrowRotator != null)
		{
			float num2 = Mathf.Lerp(-44f, 44f, Mathf.InverseLerp(-1f, 1f, normTiming));
			arrowRotator.localRotation = Quaternion.Euler(Vector3.forward * num2);
		}
		if (thumb != null)
		{
			Vector3 position = thumb.cachedTransform.position;
			Vector3[] worldCorners = container.worldCorners;
			int num3 = 0;
			int num4 = 1;
			position.y = Mathf.Lerp(worldCorners[num3].y, worldCorners[num4].y, MathEx.MapFromRangeToRange(1f, -1f, 0f, 1f, normTiming));
			thumb.cachedTransform.position = position;
		}
	}

	public override void StartThumbAnimation()
	{
		StopAllCoroutines();
	}
}
